package com.ruanjian.api.controller;

import com.ruanjian.api.bean.Person;
import com.ruanjian.api.service.impl.PersonServiceImpl;
import com.ruanjian.api.utils.AjaxResult;
import com.ruanjian.api.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author shkstart
 * @create 2022-11-30 9:34
 */
@RestController
@RequestMapping("/api/java/Person")
public class PersonController {

    @Autowired
    PersonServiceImpl personService;

    /**
     * 新增
     * @param record
     * @return
     */
    @CrossOrigin
    @PostMapping("/insertSelective")
    public int insertSelective(@RequestBody Person record){
        record.setJoinTime(DateUtil.getNowDate());
        return personService.insertSelective(record);
    }

    /**
     * 查询
     * @param record
     * @return
     */
    @CrossOrigin
    @PostMapping("/selectSelective")
    public AjaxResult selectSelective(@RequestBody Person record){
        return AjaxResult.success().add("person",personService.selectSelective(record));
    }

}
